package com.dhnsoft.boot.config;

import com.alibaba.druid.FastsqlException;
import com.dhnsoft.boot.bean.Cat;
import com.dhnsoft.boot.bean.Dog;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingClass;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author dhn
 * @version 1.0
 * @date 2023-08-17 17:29
 * @Desc
 */
@Configuration
public class AppConfig2 {

    @ConditionalOnClass(name = "com.alibaba.druid.FastsqlException")
    @Bean
    public Dog dog01(){
        return new Dog();
    }

    @ConditionalOnMissingClass(value = "com.alibaba.druid.FastsqlException")
    @Bean
    public Cat cat01(){
        return new Cat();
    }

    @ConditionalOnBean(name = "dog01")
    @Bean
    public Dog dog02(){
        return new Dog();
    }

    @ConditionalOnMissingBean(name = "dog01")
    @Bean
    public Cat cat02(){
        return new Cat();
    }
}
